package com.kpijavatraining.module.utils;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Yura
 * Date: 13.10.13
 * Time: 18:14
 * To change this template use File | Settings | File Templates.
 */



/**
 * This class - container for set of questions
 */

public class WrapperList<T> implements Iterable<T> , Cloneable , Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2833488053369065337L;
	private List<T> list = new ArrayList<T>();
		
	/**
	* method adds an item to the collection
	* @param element
	*/
	public void add(T element){
		list.add(element);
	}
			
	/**
	* method returns an iterator class
	* @return Iterator
	*/
	@Override
	public Iterator<T> iterator() {
		return list.iterator();
	}

	public T getElement(int index){
		return list.get(index);
	}
		
	public int getCountOfElements() {	
		return list.size();
	}
		
	public void delete(int index){
		list.remove(index);
	}
	
	@Override
	public WrapperList<T> clone() throws CloneNotSupportedException {	

		WrapperList<T> listOfNode = new WrapperList<T>();
		for(T q : list){
			listOfNode.add(q);
		}
		return listOfNode;
	}
}
